@echo off
REM Quick build script - Generate .exe installer with one click
REM Usage: Double-click this file or run from command line

setlocal enabledelayedexpansion

echo.
echo ========================================
echo   ELM Project Packaging Tool
echo ========================================
echo.



REM Install dependencies
echo [3/5] Installing dependencies...
if not exist node_modules (
    echo Downloading packages, please wait...
    call npm install
    if errorlevel 1 (
        echo ERROR: Failed to install dependencies
        pause
        exit /b 1
    )
) else (
    echo OK - Dependencies already exist, skipping installation
)
echo.
timeout /t 2 /nobreak

REM Generate zip archive
echo [4/5] Generating project archive...
call node build-installer.js
if errorlevel 1 (
    echo ERROR: Failed to generate archive
    pause
    exit /b 1
)
echo.
timeout /t 2 /nobreak

REM Generate .exe installer
echo [5/5] Generating .exe installer...
echo This may take 2-5 minutes, please wait...
call npm run build:win
if errorlevel 1 (
    echo ERROR: Failed to generate .exe
    pause
    exit /b 1
)
echo.
timeout /t 2 /nobreak

echo.
echo ========================================
echo   SUCCESS - Packaging complete!
echo ========================================
echo.
echo Generated files location: dist\
echo.
echo File list:
echo   - ELM Project Launcher Setup 1.0.0.exe  (Installer)
echo   - ELM Project Launcher 1.0.0.exe        (Portable)
echo   - elm-project.zip                       (Project archive)
echo.
echo Next steps:
echo   1. Double-click Setup .exe to install
echo   2. Or run portable .exe directly
echo   3. Click "Start All" button to launch services
echo.
pause
